<?php

/**
 * This is the model class for table "direct_book".
 *
 * The followings are the available columns in table 'direct_book':
 * @property integer $id
 * @property integer $event_id
 * @property integer $ticket_id
 * @property string $barcode_hash
 * @property string $barcode_salt
 * @property integer $checkin_status
 * @property integer $payment_status
 * @property integer $created_by
 * @property string $created_date
 * @property integer $updated_by
 * @property string $updated_date
 */
class DirectBook extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return DirectBook the static model class
	 */
    public $detail;
    public function __call($name, $parameters) {
        parent::__call($name, $parameters);
    }
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'direct_book';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('event_id, organizer_order_id, ticket_id, checkin_status, payment_status, created_by, updated_by', 'numerical', 'integerOnly'=>true),
			array('barcode_hash, barcode_salt, created_date, updated_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, event_id, organizer_order_id, ticket_id, barcode_hash, barcode_salt, checkin_status, payment_status, created_by, created_date, updated_by, updated_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'event' => array(self::BELONGS_TO,'Event','event_id'),
            'ticket' => array(self::BELONGS_TO,'Ticket','ticket_id'),
            'organizer_order' => array(self::BELONGS_TO,'OrganizerOrder','organizer_order_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'event_id' => 'Event',
			'ticket_id' => 'Ticket',
			'barcode_hash' => 'Barcode Hash',
			'barcode_salt' => 'Barcode Salt',
			'checkin_status' => 'Checkin Status',
			'payment_status' => 'Payment Status',
			'created_by' => 'Created By',
			'created_date' => 'Created Date',
			'updated_by' => 'Updated By',
			'updated_date' => 'Updated Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('event_id',$this->event_id);
		$criteria->compare('ticket_id',$this->ticket_id);
		$criteria->compare('barcode_hash',$this->barcode_hash,true);
		$criteria->compare('barcode_salt',$this->barcode_salt,true);
		$criteria->compare('checkin_status',$this->checkin_status);
		$criteria->compare('payment_status',$this->payment_status);
		$criteria->compare('created_by',$this->created_by);
		$criteria->compare('created_date',$this->created_date,true);
		$criteria->compare('updated_by',$this->updated_by);
		$criteria->compare('updated_date',$this->updated_date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}